define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'knscy.redpack/index',
        add_url: 'knscy.redpack/add',
        edit_url: 'knscy.redpack/edit',
        delete_url: 'knscy.redpack/delete',
        export_url: 'knscy.redpack/export',
        modify_url: 'knscy.redpack/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id', search: false},
                    {field: 'sort', title: '排序', edit: 'text', search: false, minWidth:100},
                    {field: 'redpack_no', title: '券编号', minWidth:200},
                    {field: 'redpack_type', search: 'select', selectList: {"1":"优惠券","2":"线下凭证"}, minWidth:120, title: '类型'},
                    {field: 'title', title: '券标题', minWidth:200},
                    {field: 'subtitle', title: '副标题', minWidth:200},
                    {field: 'tag', title: '标签', minWidth:150, search: false},

                    {field: 'limit_time', title: '有效期天数', search: false, minWidth:150},
                    {field: 'discount', title: '金额', minWidth:150, search: false},
                    {field: 'start_time', title: '开始时间',search:'time', minWidth:150},
                    {field: 'end_time', title: '结束时间',search:'time', minWidth:150},
                    {field: 'total_num', title: '发放数量', search: false, minWidth:150},

                    {field: 'status', search: 'select', selectList: ["禁用","启用"], minWidth:150, title: '状态', templet: ea.table.switch},
                    {field: 'create_time', title: '创建时间',search:'range', minWidth:150},
                    {fixed:"right",width: 180, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});